//
//  FCTransationFeesVC.m
//  FundChain
//
//  Created by 肖浩然的mac on 2018/3/6.
//  Copyright © 2018年 RUIXIN. All rights reserved.
//

#import "FCTransationFeesVC.h"
#import "FCAddCoinsCell.h"
#import "FCPopupView.h"
@interface FCTransationFeesVC ()<UICollectionViewDelegate,UICollectionViewDataSource>{
    UIView     *_viewNav;
    UIView     *_dimView;
}

@end

@implementation FCTransationFeesVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kWhiteColor;
    [self setNav];
    [self setupUI];
}

-(void)addpopView{
    //UIview
    _dimView = [[UIView alloc]initWithFrame:CGRectMake(0, 670*KScreenHeightScale1334, SCREEN_WIDTH, 665*KScreenHeightScale1334)];
    _dimView.backgroundColor = kWhiteColor;
    _dimView.layer.cornerRadius = 2.5;
    _dimView.layer.masksToBounds = YES;
    UIView *fristView = [UIView new];
    [_dimView addSubview:fristView];
    [fristView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(100*KScreenHeightScale1334);
    }];
    //请输入密码
    UILabel *titleLabel = [UILabel new];
    [fristView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(30*KScreenWidthScale750);
        
    }];
    titleLabel.text = Localized(@"BTC transation fee");
    titleLabel.font = Kfont(36);
    //退出按钮
    UIButton *backBtn = [UIButton new];
    [fristView addSubview:backBtn];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-30*KScreenWidthScale750);
    }];
    [backBtn setImage:[UIImage imageNamed:@"cancel"] forState:UIControlStateNormal];
    //分割线
    UIView *viewLine =[UIView new];
    [_dimView addSubview:viewLine];
    [viewLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(fristView.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    viewLine.backgroundColor =kLineColor;
    
    //Amount
    UILabel *amountLabel = [UILabel new];
    [_dimView addSubview:amountLabel];
    [amountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(30*KScreenWidthScale750);
        make.top.mas_equalTo(viewLine.mas_bottom).offset(40*KScreenHeightScale1334);
        
    }];
    amountLabel.font = Kfont(32);
    amountLabel.text = @"The fee value is per kilobtye of transation data";
    amountLabel.textColor = kGrayColor;
    //rateField
    UITextField *rateField = [UITextField new];
    [_dimView addSubview:rateField];
    [rateField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(amountLabel.mas_bottom).offset(60*KScreenHeightScale1334);
        make.left.mas_equalTo(30*KScreenWidthScale750);
        make.width.mas_equalTo(480*KScreenWidthScale750);
    }];
    rateField.font = Kfont(40);
    //币种
    UILabel *moneyTypeLabel = [UILabel new];
    [_dimView addSubview:moneyTypeLabel];
    [moneyTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(rateField);
        make.bottom.mas_equalTo(rateField.mas_bottom).offset(-2);
        
    }];
    moneyTypeLabel.font = Kfont(36);
    moneyTypeLabel.text = @"BTC";
    moneyTypeLabel.textColor = kGrayColor;
    //分割线
    UIView *viewLine1 =[UIView new];
    [_dimView addSubview:viewLine1];
    [viewLine1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(rateField);
        make.top.mas_equalTo(rateField.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    viewLine1.backgroundColor =kLineColor;
    //default fee
    UILabel *defaultFeeLabel = [UILabel new];
    [_dimView addSubview:defaultFeeLabel];
    [defaultFeeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(viewLine1);
        make.top.mas_equalTo(viewLine1.mas_bottom).offset(20*KScreenHeightScale1334);
        
    }];
    defaultFeeLabel.font = Kfont(32);
    defaultFeeLabel.text = @"Default fee";
    defaultFeeLabel.textColor = kRedOrangeColor;
    //okbtn
    UIButton *okbtn = [UIButton new];
    [_dimView addSubview:okbtn];
    [okbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(30*KScreenWidthScale750);
        make.right.mas_equalTo(-30*KScreenWidthScale750);
        make.top.mas_equalTo(defaultFeeLabel.mas_bottom).offset(110*KScreenHeightScale1334);
        make.height.mas_equalTo(112*KScreenHeightScale1334);
    }];
    okbtn.layer.cornerRadius = 5.0;
    okbtn.layer.masksToBounds = YES;
    okbtn.titleLabel.font = KOverstrikingfont(36);
    [okbtn setTitle:Localized(@"OK") forState:(UIControlStateNormal)];
    [okbtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
    [okbtn setBackgroundColor:kRedOrangeColor];
    //事件
    [backBtn addTarget:self action:@selector(backBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [FCPopupView showWithView:_dimView];
    
    
}
//返回
-(void)backBtnClick{
    [FCPopupView dissMiss];
}
#pragma mark-UIcollectionView&UICollectionViewDataSource

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return 5;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    return CGSizeMake(320*KScreenWidthScale750, 292*KScreenHeightScale1334);
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    FCAddCoinsCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"addCoinsCollectionViewCell" forIndexPath:indexPath];
    
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    //    FCAddCoinsCell *item = (FCAddCoinsCell*)[collectionView cellForItemAtIndexPath:indexPath];
    NSLog(@"点击了%zd",indexPath.item);
    
    [self addpopView];
}
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    //    FCAddCoinsCell *item = (FCAddCoinsCell*)[collectionView cellForItemAtIndexPath:indexPath];
    NSLog(@"取消点击了%zd",indexPath.item);
    
}
#pragma mark-设置UI
-(void)setupUI{
    
    //设置瀑布流
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    [layout setScrollDirection:(UICollectionViewScrollDirectionVertical)];
    //    layout.minimumLineSpacing = 10=;// 水平方向的间距
    //    layout.minimumInteritemSpacing = 10;
    layout.sectionInset = UIEdgeInsetsMake(0, 15, 10, 15);
    UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
    [self.view addSubview:collectionView];
    [collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_viewNav.mas_bottom).offset(30*KScreenHeightScale1334);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    collectionView.delegate = self;
    collectionView.dataSource = self;
    collectionView.backgroundColor = [UIColor clearColor];
    [collectionView registerClass:[FCAddCoinsCell class] forCellWithReuseIdentifier:@"addCoinsCollectionViewCell"];
    //设置可以多选
    collectionView.allowsMultipleSelection=YES;
    
    
}
#pragma mark-设置导航栏
-(void)setNav{
    self.navigationController.navigationBarHidden = YES;
    _viewNav =[UIView new];
    [self.view addSubview:_viewNav];
    [_viewNav mas_makeConstraints:^(MASConstraintMaker *make) {
        if (@available(iOS 11.0, *)) {
            if (iPhoneX) {
                
                make.left.right.top.mas_equalTo(self.view.safeAreaInsets);
                make.height.mas_equalTo(88);
            }else{
                make.left.right.mas_equalTo(0);
                make.height.mas_equalTo(64);
                make.top.mas_equalTo(0);
            }
        }else{
            make.left.right.mas_equalTo(0);
            make.height.mas_equalTo(64);
            make.top.mas_equalTo(0);
        }
        
    }];
    _viewNav.backgroundColor = kRedOrangeColor;
    
    UIButton *leftBtn = [UIButton new];
    [self.view addSubview:leftBtn];
    [leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15*KScreenWidthScale750);
        make.centerY.mas_equalTo(_viewNav.mas_centerY).offset(8);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    [leftBtn setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];
    
    [leftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    //返回
    UILabel *backLabel = [UILabel new];
    
    [_viewNav addSubview:backLabel];
    [backLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_viewNav);
        make.centerY.mas_equalTo(_viewNav.mas_centerY).offset(8);
    }];
    backLabel.text = Localized(@"手续费");
    backLabel.textColor = [UIColor whiteColor];
    backLabel.font = KOverstrikingfont(36);
    
    //事件
    [leftBtn addTarget:self action:@selector(leftBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
}
-(void)leftBtnClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}


@end
